public class test1 {
    // 力扣 1567.乘积为正数的最长子数组的长度
    public int getMaxLen(int[] nums) {
        //创建dp表
        //初始化
        //填表
        //返回值
        int n = nums.length;
        int[] dpf = new int[n+1];
        int[] dpg = new int[n+1];

        int max = Integer.MIN_VALUE;
        for(int i = 1;i<n+1;i++){
            if(nums[i-1]>0){
                dpf[i] = dpf[i-1]+1;
                dpg[i] = dpg[i-1]==0?0:dpg[i-1]+1;
            }else if(nums[i-1]<0){
                dpf[i] = dpg[i-1]==0?0:dpg[i-1]+1;
                dpg[i] = dpf[i-1]+1;

            }
            max = Math.max(dpf[i], max);
        }
        return max;
    }
}
